#include <iostream>
#include "signal.h"
#include "ChatServer.h"
#include "ChatService.h"
#include "Pool.h"


//处理服务器停止时的状况
void resetHandler(int){
    ChatService::getInstance()->reset();
    exit(0);
}

int main(int argc ,char** argv)
{
//    if(argc<3){
//        std::cerr<<"command invalid! example: ./server 127.0.0.1 8000"<<std::endl;
//        exit(-1);
//    }
    signal(SIGINT,resetHandler);
    signal(SIGTERM,resetHandler);
    signal(SIGKILL,resetHandler);
    auto a = Pool::getInstance();
    EventLoop loop;
//    char* ip = argv[1];
    char* ip = "127.0.0.1";
//    uint16_t port = atoi(argv[2]);
    uint16_t port = 6000;
    InetAddress addr(ip,port);
    ChatServer server(&loop,addr,"ChatServer");
    server.start();
    loop.loop();
}
